package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/31 17:32
 **/
public class Day46_7_Offer29_Ⅱ_SpiralOrder {
    public static void main(String[] args) {
        spiralOrder(new int[][]{{1,2,3}, {4,5,6}, {7,8,9}});
    }
    // 顺序打印
    public static int[] spiralOrder(int[][] matrix) {
        int m = matrix.length, n = matrix[0].length, i = 0;
        int len = m * n;
        int[] ans = new int[len];
        while(i < len){
            System.out.println(i);
            ans[i] = matrix[i/n][i%n];
            i++;
        }
        return ans;
    }

}